<template>
	<view>
		<GoodsList :hotDoorGoods='hotDoorGoods' :hotDoorGoodsImage='hotDoorGoodsImage' />
	</view>
</template>

<script>
	import GoodsList from '@/components/goodsList.vue'
	export default {
		data() {
			return {
				// 热门商品数据
				hotDoorGoods: [],
				// 热门商品图片
				hotDoorGoodsImage: [
					'//gw.alicdn.com/bao/upload/O1CN01oVqQx41mUoPHJzeUc_!!6000000004958-2-yinhe.png',
					'//gw.alicdn.com/bao/upload/O1CN01VwgRNv1X5sbpYucDM_!!6000000002873-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01WvkTu21GEGOMzBW0V_!!6000000000590-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01LDIOZE1t4tIif7fiK_!!6000000005849-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01QP5xYu1VTZs9lVVqn_!!6000000002654-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01O22k1o1qYFqVAYl9D_!!6000000005507-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01rKFawo1ag0haJcmKj_!!6000000003358-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01CyjsN71Y6csF3v9Sj_!!6000000003010-2-yinhe.png',
					'//gw.alicdn.com/bao/upload/O1CN01sH9nVR296IN2BqCq3_!!6000000008018-0-yinhe.jpg_Q75.jpg',
					'//gw.alicdn.com/bao/upload/O1CN01mkLtjG1sy1MYNblLA_!!6000000005834-0-yinhe.jpg_Q75.jpg'
				],
				// 下拉加载更多
				pageindex:1
			}
		},
		components:{
			GoodsList
		},
		onLoad() {
			this.reqHotDoorGoods();
		},
		methods: {
			async reqHotDoorGoods() {
				if(this.hotDoorGoods.length % 10 !== 0) return
				const {
					data
				} = await this.$myRequest({
					url: `/api/getgoods?pageindex=${this.pageindex}` 
				});
				this.hotDoorGoods.push(...data.message);
			},
		},
		onReachBottom() {
			this.pageindex++;
			this.reqHotDoorGoods();
		},
		onPullDownRefresh() {
			this.pageindex = 1;
			this.hotDoorGoods = [];
			this.reqHotDoorGoods();
			uni.stopPullDownRefresh();
		}
	}
</script>

<style>

</style>
